import './assets/main.css'
import axios from "axios"
import 'vant/lib/index.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
import { Popup, CountDown, Dialog, Field, Popover, FloatingPanel  } from 'vant';

import { draggable } from "@/util/draggable";
import { v4 as uuidv4 } from 'uuid';

// 生成并存储设备唯一标识符
const deviceId = localStorage.getItem('deviceId') || uuidv4();
localStorage.setItem('deviceId', deviceId);




// 使用配置
loadConfig().then((config) => {
    const app = createApp(App);

     app.directive('resizable', draggable);
     app.config.globalProperties.$deviceId = deviceId;
    app
      .use(FloatingPanel)
      .use(Popover)
      .use(Field)
      .use(Dialog)
      .use(CountDown)
      .use(Popup)
      .use(createPinia())
      .use(router)
      .mount("#app");
  
    app.provide("globalConfig", config);

    
  });
  
  // 加载配置
  async function loadConfig() {
    const langData = await axios.get("./lang/lang.json");  //语言文件
    const quickerData = await axios.get("./quicker/quicker.json");  //快捷回复文件

    let configure = {
      lang: langData.data,
      quicker:quickerData.data
    }
    // console.log(response.data)
    return configure;
  }

  


  